package com.oocl.util;

import java.text.ParseException;
import java.text.SimpleDateFormat;

public class FormValid {
	public boolean validUname(String uname){
		if("".endsWith(uname) || uname == null){
			return false;
		}else{
			return true;
		}
	}
	
	public boolean validSal(String sal){
		boolean flag = true;
		
		if("".equals(sal) || sal == null){
			flag = false;
		}
		
		
		try {
			double sum = Double.valueOf(sal);
			if( sum > 10000000 || sum <= 0){
				flag = false;
			}else{
				flag = true;
			}
		} catch (NumberFormatException e) {
			flag = false;
		}
		
		return flag;
	}
	
	public boolean validBirth(String birth){
		boolean flag = true;
		try {
			SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
			sdf.setLenient(true);
			sdf.parse(birth);
		} catch (ParseException e) {
			flag = false;
		}
		return flag;
	}
	
	public boolean validSex(String sex){
		if( "0".equals(sex) || "1".equals(sex)){
			return true;
		}else{
			return false;
		}
	}
	
}
